(bug 30488) API now allows listing of backlinks/embeddedin/imageusage
authorumherirrender <umherirrender_de.wp@web.de>
Sun, 29 Apr 2012 20:10:11 +0000 (22:10 +0200)
committerReedy <reedy@wikimedia.org>
Wed, 2 May 2012 00:35:04 +0000 (01:35 +0100)
per pageid

Move the possibles errors set by ApiBase::getTitleOrPageId to
ApiBase::getTitleOrPageIdErrorMessages and remove it from used modules

Change-Id: If037e04665d2524c1f2476bc7996d9573753a4b8

RELEASE-NOTES-1.20
includes/api/ApiBase.php
includes/api/ApiDelete.php
includes/api/ApiEditPage.php
includes/api/ApiProtect.php
includes/api/ApiQueryBacklinks.php
includes/api/ApiQueryCategoryMembers.php

index c77a4eb..1b35ad5 100644 (file)
@@ -103,6 +103,7 @@ production.
 * (bug 32497) API now allows changing of protection level using pageid
 * (bug 32498) API now allows comparing pages using pageids
 * (bug 30975) API import of pages with invalid characters in this wiki leads to Fatal Error
+* (bug 30488) API now allows listing of backlinks/embeddedin/imageusage per pageid
 
 === Languages updated in 1.20 ===
 
index 1103814..fc2ef77 100644 (file)
@@ -723,8 +723,14 @@ abstract class ApiBase extends ContextSource {
        /**
         * @return array
         */
-       public function getTitleOrPageIdErrorMessage( ) {
-               return $this->getRequireOnlyOneParameterErrorMessages( array( 'title', 'pageid' ) );
+       public function getTitleOrPageIdErrorMessage() {
+               return array_merge(
+                       $this->getRequireOnlyOneParameterErrorMessages( array( 'title', 'pageid' ) ),
+                       array(
+                               array( 'invalidtitle', 'title' ),
+                               array( 'nosuchpageid', 'pageid' ),
+                       )
+               );
        }
 
        /**
index 15c1f82..21e7b80 100644 (file)
@@ -230,8 +230,6 @@ class ApiDelete extends ApiBase {
                return array_merge( parent::getPossibleErrors(),
                        $this->getTitleOrPageIdErrorMessage(),
                        array(
-                               array( 'invalidtitle', 'title' ),
-                               array( 'nosuchpageid', 'pageid' ),
                                array( 'notanarticle' ),
                                array( 'hookaborted', 'error' ),
                                array( 'delete-toobig', 'limit' ),
index b45f351..11f4757 100644 (file)
@@ -371,9 +371,7 @@ class ApiEditPage extends ApiBase {
                return array_merge( parent::getPossibleErrors(),
                        $this->getTitleOrPageIdErrorMessage(),
                        array(
-                               array( 'nosuchpageid', 'pageid' ),
                                array( 'missingtext' ),
-                               array( 'invalidtitle', 'title' ),
                                array( 'createonly-exists' ),
                                array( 'nocreate-missing' ),
                                array( 'nosuchrevid', 'undo' ),
index 57bf111..97e79ff 100644 (file)
@@ -192,8 +192,6 @@ class ApiProtect extends ApiBase {
                return array_merge( parent::getPossibleErrors(),
                        $this->getTitleOrPageIdErrorMessage(),
                        array(
-                               array( 'invalidtitle', 'title' ),
-                               array( 'nosuchpageid', 'pageid' ),
                                array( 'toofewexpiries', 'noofexpiries', 'noofprotections' ),
                                array( 'create-titleexists' ),
                                array( 'missingtitle-createonly' ),
index 381ef55..bf9aa3d 100644 (file)
@@ -369,14 +369,7 @@ class ApiQueryBacklinks extends ApiQueryGeneratorBase {
                if ( !is_null( $this->params['continue'] ) ) {
                        $this->parseContinueParam();
                } else {
-                       if ( $this->params['title'] !== '' ) {
-                               $title = Title::newFromText( $this->params['title'] );
-                               if ( !$title ) {
-                                       $this->dieUsageMsg( array( 'invalidtitle', $this->params['title'] ) );
-                               } else {
-                                       $this->rootTitle = $title;
-                               }
-                       }
+                       $this->rootTitle = $this->getTitleOrPageId( $this->params );
                }
 
                // only image titles are allowed for the root in imageinfo mode
@@ -436,7 +429,9 @@ class ApiQueryBacklinks extends ApiQueryGeneratorBase {
                $retval = array(
                        'title' => array(
                                ApiBase::PARAM_TYPE => 'string',
-                               ApiBase::PARAM_REQUIRED => true
+                       ),
+                       'pageid' => array(
+                               ApiBase::PARAM_TYPE => 'integer',
                        ),
                        'continue' => null,
                        'namespace' => array(
@@ -468,7 +463,8 @@ class ApiQueryBacklinks extends ApiQueryGeneratorBase {
 
        public function getParamDescription() {
                $retval = array(
-                       'title' => 'Title to search',
+                       'title' => "Title to search. Cannot be used together with {$this->bl_code}pageid",
+                       'pageid' => "Pageid to search. Cannot be used together with {$this->bl_code}title",
                        'continue' => 'When more results are available, use this to continue',
                        'namespace' => 'The namespace to enumerate',
                );
@@ -499,11 +495,13 @@ class ApiQueryBacklinks extends ApiQueryGeneratorBase {
        }
 
        public function getPossibleErrors() {
-               return array_merge( parent::getPossibleErrors(), array(
-                       array( 'invalidtitle', 'title' ),
-                       array( 'code' => 'bad_image_title', 'info' => "The title for {$this->getModuleName()} query must be an image" ),
-                       array( 'code' => '_badcontinue', 'info' => 'Invalid continue param. You should pass the original value returned by the previous query' ),
-               ) );
+               return array_merge( parent::getPossibleErrors(),
+                       $this->getTitleOrPageIdErrorMessage(),
+                       array(
+                               array( 'code' => 'bad_image_title', 'info' => "The title for {$this->getModuleName()} query must be an image" ),
+                               array( 'code' => '_badcontinue', 'info' => 'Invalid continue param. You should pass the original value returned by the previous query' ),
+                       )
+               );
        }
 
        public function getExamples() {
index 7f0b827..8fff94d 100644 (file)
@@ -374,7 +374,6 @@ class ApiQueryCategoryMembers extends ApiQueryGeneratorBase {
                        array(
                                array( 'code' => 'invalidcategory', 'info' => 'The category name you entered is not valid' ),
                                array( 'code' => 'badcontinue', 'info' => 'Invalid continue param. You should pass the original value returned by the previous query' ),
-                               array( 'nosuchpageid', 'pageid' ),
                        )
                );
        }